package com.lcf.order.controller;

import com.lcf.order.client.StreamClient;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * Created by lancf on 2019/7/12.
 */
@RestController
public class MqController {

    @Autowired
    private AmqpTemplate amqpTemplate;

//    @Autowired
//    private StreamClient streamClient;
//
//    @Autowired
//    public MqController(StreamClient streamClient){
//        this.streamClient= streamClient;
//    }

    /**
     * 原生RabbitMQ发送消息
     */
    @GetMapping("/sendMsg")
    public String sendMsg() {

        String res = "now" + new Date();
        amqpTemplate.convertAndSend("myqueue", "now==>" + new Date());
        return res;
    }

    /**
     * 原生RabbitMQ发送消息
     */
    @GetMapping("/sendMsg2")
    public String sendMsg2() {

        String res = "now" + new Date();
        amqpTemplate.convertAndSend("myQueue2", "now==>" + new Date());
        return res;
    }

    /**
     * 原生RabbitMQ发送消息
     */
    @GetMapping("/sendMsgKey")
    public String sendMsgKey() {

        String res = "now" + new Date();
        amqpTemplate.convertAndSend("myOrder", "furit", "now==>" + new Date());
        return res;
    }


}
